<?php
require_once './Unireset/Unirest.php';
class Index extends CI_Controller {
	public function __construct(){
		parent::__construct(); //必须初始化！！！！！！
	}
	/**
	* index方法，将来可以用作欢迎页面
	*/
	public function index(){
		print("hello world");
	}
	public function jiami(){
		$this->load->library('encryption');
		$str = array(
			"username" => "0x007er",
			"password" => "pass"
		);
		$key = "188012174";
		
		//var_dump($key);
		//var_dump($this->encryption->encrypt($str));
		$msg = base64_encode($this->encryption->encrypt(
			$str,
			array(
				'cipher' => 'blowfish',
				'mode' => 'cbc',
				'key' => $key,
				'hmac_digest' => 'sha256',
				'hmac_key' => FALSE
			)
		));
		var_dump($msg."<br />");
		
		$msg1 = $this->encryption->decrypt(
			base64_decode($msg),
			array(
				'cipher' => 'blowfish',
				'mode' => 'cbc',
				'key' => $key,
				'hmac_digest' => 'sha256',
				'hmac_key' => FALSE
			)
		);
		var_dump($msg1);
	}
	public function test(){
		print("<pre/>");
		var_dump($_POST);
	}
	public function testurl(){
		$headers = array("Accept" => "application/json");
		$body = array(
			"username" => "0x007er",
			"pass" => "0x007erpass"
		);	
		$response = Unirest\Request::post("http://127.0.0.1:8080/CloudFlag-IOS/index.php/index/test", $headers, $body);
		print_r($response->body);
	}
		
}